package com.whmskj.xjlhsc.mobie.personnelFile.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import com.whmskj.xjlhsc.mobie.personnelFile.dto.LeaveApplicationListDTO;
import com.whmskj.xjlhsc.mobie.personnelFile.dto.LeaveApplicationDetailDTO;

@Mapper
public interface LeaveApplicationMapper {
    int insert(Map<String, Object> entity);
    int updateSelective(Map<String, Object> entity);
    int updateStatus(@Param("id") Integer id,
                     @Param("status") String status,
                     @Param("cancelReason") String cancelReason,
                     @Param("approverId") Integer approverId,
                     @Param("approverName") String approverName,
                     @Param("updateTime") LocalDateTime updateTime);

    LeaveApplicationDetailDTO selectById(@Param("id") Integer id);

    List<LeaveApplicationListDTO> selectList(@Param("employeeId") Integer employeeId,
                                         @Param("employeeName") String employeeName,
                                         @Param("status") String status,
                                         @Param("startFrom") LocalDateTime startFrom,
                                         @Param("endTo") LocalDateTime endTo);

    // 性别统计（与列表相同筛选条件）
    Map<String, Object> countByGender(@Param("employeeId") Integer employeeId,
                                      @Param("employeeName") String employeeName,
                                      @Param("status") String status,
                                      @Param("startFrom") LocalDateTime startFrom,
                                      @Param("endTo") LocalDateTime endTo);

    // 简易员工搜索（供选择器使用）
    List<Map<String, Object>> searchEmployees(@Param("keyword") String keyword,
                                              @Param("limit") Integer limit);

    // 他人已审核 + 我的全部
    List<LeaveApplicationListDTO> selectAllView(@Param("myEmployeeId") Integer myEmployeeId,
                                            @Param("employeeName") String employeeName,
                                            @Param("startFrom") LocalDateTime startFrom,
                                            @Param("endTo") LocalDateTime endTo);

    // 待我审批（当前节点）
    List<LeaveApplicationListDTO> selectPendingForApprover(@Param("approverId") Integer approverId,
                                                       @Param("employeeName") String employeeName,
                                                       @Param("startFrom") LocalDateTime startFrom,
                                                       @Param("endTo") LocalDateTime endTo);

    // 合并接口：我已处理
    List<LeaveApplicationListDTO> selectHandledByMe(@Param("myEmployeeId") Integer myEmployeeId,
                                                @Param("result") String result,
                                                @Param("employeeName") String employeeName,
                                                @Param("startFrom") LocalDateTime startFrom,
                                                @Param("endTo") LocalDateTime endTo);

    int selectRestNum(@Param("empName") String empName,
                      @Param("class55") String class55);
}
